'use strict';
const db = uniCloud.database()
exports.main = async (event, context) => {
	let apiUrl='https://v2.alapi.cn/api/zaobao'
	const {data} = await uniCloud.httpclient.request(apiUrl, {
	    method: 'GET',
	    data: {
	      format:"json",
	      token:"K8NVh0xvERNNSX1l"
	    },
	    contentType: 'json', 
	    dataType: 'json' 
	  })   
	  if(data.code===200){
		  let res = await db.collection('mor_news').add({
		    date: data.data.date,
		    news: data.data.news,
		    weiyu: data.data.weiyu,
		    image: data.data.image,
		    head_image: data.data.head_image,
		  })
		  console.log(res);
		  return res
	  }
	  // console.log(data);
	  // return data.code===200
};
